#ifndef STRINGLOGGER_HPP
#define STRINGLOGGER_HPP
#include <string>
#include <iostream>
#include "message.h"
#define LOG StringLogger::getInstance()


class StringLogger
{
public:
    static StringLogger& getInstance()
    {
        if(instance == 0)
            instance = new StringLogger();
        return *instance;
    }
    virtual ~StringLogger()
    {
        if(instance != 0)
          delete instance;
    }
    template<typename LoggedType>
    StringLogger& operator<<(const LoggedType& log)
    {
        std::cout << log;
        return *instance;
    }

    StringLogger& operator<<(const std::vector<Message>& log)
    {
        for(std::vector<Message>::const_iterator i = log.begin(); i!=log.end();++i)
            LOG << *i;
        return *instance;
    }
    StringLogger& operator<<(const Data& bytes)
    {
        for(Data::const_iterator i = bytes.begin(); i != bytes.end();++i)
            std::cout << std::hex << (int)*i;
        std::cout << "\n";
        return *instance;
    }
    StringLogger& operator<<(const Message& msg)
    {
        Data bytes = msg.getMsgBytes();

        for(Data::iterator i = bytes.begin(); i != bytes.end();++i)
            std::cout << std::hex << (int)*i;
        std::cout << "\n";
        return *instance;
    }
private:
    StringLogger()
    {}
    StringLogger(const StringLogger&);
    StringLogger& operator=(const StringLogger&);
    static StringLogger* instance;
    void logString();
};
#endif // STRINGLOGGER_HPP
